package com.sjq.demo.producer;

import javax.jms.Destination;
import javax.jms.ObjectMessage;
import javax.jms.Queue;

import org.springframework.stereotype.Component;

import com.sjq.common.mq.base.AbstractJMSProducer;


@Component
public class DemoJMSProducer extends AbstractJMSProducer {

	@Override
	public String specifyDestinationName() {
		//////////////设置名字
		return "sjq_msg_queue";
	}

	@Override
	public Class<? extends Destination> specifyDestinationClass() {
		return Queue.class;
	}
	
	
	public void sendMessageToMQ() {
		try{
			ObjectMessage message = session.createObjectMessage("msg demo") ;
			this.messageProducer.send(message);
		}catch(Exception ex){
			ex.printStackTrace();
			try{
				stop();
			}catch(Exception e0){
				e0.printStackTrace();
			}
			try{
				start();
			}catch(Exception e1){
				e1.printStackTrace();
			}
		}
	}
	
	

}
